home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / java / slideshow / sources (skeleton) / rolloverbutton.java < prev    next >
Encoding:
Java Source  |  2000-06-23  |  2.0 KB  |  69 lines

  1. /**
  2.  * An abstract class to implement the functionality associated with
  3.  * a "roll over button."  The basic behavior is such that when the mouse
  4.  * is "rolled over" the button, the button reacts by displaying a
  5.  * different image to give instant feedback to the user.
  6.  */
  7. public abstract class RolloverButton extends ImageButton
  8. {
  9.     //Declare data members
  10.     //Insert "RolloverButton data members"
  11.     
  12.     /**
  13.      * Constructs a default instance of this class.
  14.      */
  15.     public RolloverButton()
  16.     {
  17.         //Initialize the state of the button
  18.         //Insert "RolloverButton init state"
  19.     }
  20.     
  21.     /**
  22.      * Sub classes need to define this to handle initializing their
  23.      * images, and state information.
  24.      */
  25.     protected abstract void initImages();
  26.     
  27.     /**
  28.      * Sets the button to be in the correct configuration for the
  29.      * current state.
  30.      */
  31.     public void refreshImage()
  32.     {
  33.         //Handle determining the current state, and reacting appropriately
  34.         //Insert "RolloverButton refreshImage"
  35.     }
  36.     
  37.     /**
  38.      * Gets called when the mouse button is pressed on this button.
  39.      */
  40.     protected void handleMousePressed()
  41.     {
  42.         //Set the image to the appropriate image for a mouse press.
  43.         //Insert "RolloverButton mousePressed"
  44.     }
  45.  
  46.     /**
  47.      * Gets called when the mouse button is released on this button.
  48.      * @param isMouseInside, if true, the mouse is located inside the button area,
  49.      * if false the mouse is outside the button area.
  50.      */
  51.     protected void handleMouseRelease(boolean isMouseInside)
  52.     {
  53.         //Set the image to the appropriate image for a mouse release,
  54.         //and calls the super classes version to include inherited functionality.
  55.         //Insert "RolloverButton mouseReleased"
  56.     }
  57.  
  58.     /**
  59.      * Gets called when the mouse crosses into or out of the button area.
  60.      * @param isMouseInside, is true if the mouse is in the button area,
  61.      * false if it is outside.
  62.      * @param isMouseDown, is true if the mouse button is pressed, false if it is not.
  63.      */
  64.     protected void handleRollover(boolean isMouseInside, boolean isMouseDown)
  65.     {
  66.         //Handle determining the current state, and reacting appropriately
  67.         //Insert "RolloverButton handleRollover"
  68.     }
  69. }